<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>参数配置管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				/* rules : {
					checkValue : {
						remote : "${ctx}/sysparams/sysParams/checkValue?paramCode="
								+ $("#inputForm select[name=paramCode]").val() + "&paramValue="
								+ $("#inputForm input[name=paramValue]").val() + "&id=${sysParams.id}"
					}
				},
				messages : {
					checkValue : {
						remote : "分成比例已超出总比例"
					}
				}, */
				submitHandler: function(form){
					$.post(
						"${ctx}/sysparams/sysParams/checkValue?r="+Math.random(),
						{
							paramType:$("#inputForm select[name=paramType]").val(),
							/* paramCode:$("#inputForm select[name=paramCode]").val(), */
							paramValue:$("#inputForm input[name=paramValue]").val(),
							id:"${sysParams.id}"/* ,paramName:$("#inputForm select[name=paramName]").val() */
						},
						function(json) {
							if(json.result==false){
								top.$.jBox.tip(json.msg,'warning');
							} else {
								loading('正在提交，请稍等...');
								form.submit();
							}
						}, "json");
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/sysparams/sysParams/">参数配置列表</a></li>
		<li class="active">
			<a href="${ctx}/sysparams/sysParams/form?id=${sysParams.id}&paramCode=${sysParams.paramCode}">
				<c:choose><c:when test="${sysParams.paramCode == '1'}">平台收益</c:when><c:when test="${sysParams.paramCode == '2'}">试算</c:when><c:when test="${sysParams.paramCode == '0'}">普通</c:when></c:choose>参数配置
				<shiro:hasPermission name="sysparams:sysParams:edit">${not empty sysParams.id?'修改':'添加'}</shiro:hasPermission>
				<shiro:lacksPermission name="sysparams:sysParams:edit">查看</shiro:lacksPermission>
			</a>
		</li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="sysParams" action="${ctx}/sysparams/sysParams/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="paramCode"/>
		<sys:message content="${message}"/>	
		<c:if test="${sysParams.paramCode == '1' }">
			<div class="control-group">
				<label class="control-label">参数类型：</label>
				<div class="controls">
					<form:select path="paramType" class="input-xlarge ">
						<form:option value="" label=""/>
						<form:options items="${fns:getDictList('platform_pumping')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
				</div>
			</div>
		</c:if>	
		<c:if test="${sysParams.paramCode == '2' }">
			<div class="control-group">
				<label class="control-label">参数名：</label>
				<div class="controls">
					<form:hidden path="paramType"/>
					<form:input path="paramName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
		</c:if>
		<c:if test="${sysParams.paramCode == '0' || sysParams.paramType == '6' }">
			<div class="control-group">
				<label class="control-label">参数名：</label>
				<div class="controls">
					<form:hidden path="paramType"/>
					<c:choose>
						<c:when test="${not empty sysParams.id }">
							<form:input readonly="true" path="paramName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
						</c:when>
						<c:otherwise>
							<form:input path="paramName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
						</c:otherwise>
					</c:choose>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
		</c:if>
		<%-- <div class="control-group">
			<label class="control-label">类型所属选择：</label>
			<div class="controls">
				<form:select path="paramCode" class="input-xlarge ">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('work_order_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">类型分配角色：</label>
			<div class="controls">
				<form:select path="paramName" class="input-xlarge ">
					<form:option value="" label=""/>
					<form:options items="${allRoles}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">参数值：</label>
			<div class="controls">
				<form:input path="paramValue" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">描述：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="1000" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="sysparams:sysParams:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>